'''
Created on Aug 4, 2012

@author: cmbruns
'''

_elements_by_symbol = dict()


class Element(object):
    # In nanometers!
    def __init__(self, atomic_number, symbol, name, mass=10.0, vdw_radius=0.20, covalent_radius=0.08):
        self.atomic_number = atomic_number
        self.symbol = symbol
        self.name = name
        self.vdw_radius = vdw_radius
        self.covalent_radius = covalent_radius
        _elements_by_symbol[symbol.upper().strip()] = self


hydrogen      = Element( 1,  "H", "hydrogen", 1.008, 0.120, 0.023)
helium        = Element( 2, "He", "helium", 4.003, 0.140, 0.150)
lithium       = Element( 3, "Li", "lithium", 6.941, 0.182, 0.128)
beryllium     = Element( 4, "Be", "beryllium", 9.012, 0.200, 0.096)
boron         = Element( 5,  "B", "boron", 10.811, 0.200, 0.083)
carbon        = Element( 6,  "C", "carbon", 12.011, 0.170, 0.068)
nitrogen      = Element( 7,  "N", "nitrogen", 14.007, 0.155, 0.068)
oxygen        = Element( 8,  "O", "oxygen", 15.999, 0.152, 0.068)
fluorine      = Element( 9,  "F", "fluorine", 18.998, 0.147, 0.064)
neon          = Element(10, "Ne", "neon", 20.180, 0.154, 0.150)
sodium        = Element(11, "Na", "sodium", 22.990, 0.227, 0.166)
magnesium     = Element(12, "Mg", "magnesium", 24.305, 0.173, 0.141)
aluminum      = Element(13, "Al", "aluminum", 26.982, 0.200, 0.121)
silicon       = Element(14, "Si", "silicon", 28.086, 0.210, 0.120)
phosphorus    = Element(15,  "P", "phosphorus", 30.974, 0.180, 0.105)
sulfur        = Element(16,  "S", "sulfur", 32.066, 0.180, 0.102)
chlorine      = Element(17, "Cl", "chlorine", 35.453, 0.175, 0.099)
argon         = Element(18, "Ar", "argon", 39.948, 0.188, 0.151)
potassium     = Element(19,  "K", "potassium", 39.098, 0.275, 0.203)
calcium       = Element(20, "Ca", "calcium", 40.078, 0.200, 0.176)
scandium      = Element(21, "Sc", "scandium", 44.956, 0.200, 0.170)
titanium      = Element(22, "Ti", "titanium", 47.867, 0.200, 0.160)
vanadium      = Element(23,  "V", "vanadium", 50.942, 0.200, 0.153)
chromium      = Element(24, "Cr", "chromium", 51.996, 0.200, 0.139)
manganese     = Element(25, "Mn", "manganese", 54.938, 0.200, 0.161)
iron          = Element(26, "Fe", "iron", 55.845, 0.200, 0.152)
cobalt        = Element(27, "Co", "cobalt", 58.933, 0.200, 0.126)
nickel        = Element(28, "Ni", "nickel", 58.693, 0.163, 0.124)
copper        = Element(29, "Cu", "copper", 63.546, 0.140, 0.132)
zinc          = Element(30, "Zn", "zinc", 65.380, 0.139, 0.122)
gallium       = Element(31, "Ga", "gallium", 69.723, 0.187, 0.122)
germanium     = Element(32, "Ge", "germanium", 72.630, 0.200, 0.117)
arsenic       = Element(33, "As", "arsenic", 74.922, 0.185, 0.122)
selenium      = Element(34, "Se", "selenium", 78.960, 0.190, 0.122)
bromine       = Element(35, "Br", "bromine", 79.904, 0.185, 0.121)
krypton       = Element(36, "Kr", "krypton", 83.798, 0.202, 0.150)
rubidium      = Element(37, "Rb", "rubidium", 85.468, 0.200, 0.220)
strontium     = Element(38, "Sr", "strontium", 87.620, 0.200, 0.195)
yttrium       = Element(39,  "Y", "yttrium", 88.906, 0.200, 0.190)
zirconium     = Element(40, "Zr", "zirconium", 91.224, 0.200, 0.175)
niobium       = Element(41, "Nb", "niobium", 92.906, 0.200, 0.164)
molybdenum    = Element(42, "Mo", "molybdenum", 95.960, 0.200, 0.154)
technetium    = Element(43, "Tc", "technetium", 98.0, 0.200, 0.147)
ruthenium     = Element(44, "Ru", "ruthenium", 101.070, 0.200, 0.146)
rhodium       = Element(45, "Rh", "rhodium", 102.906, 0.200, 0.145)
palladium     = Element(46, "Pd", "palladium", 106.420, 0.163, 0.139)
silver        = Element(47, "Ag", "silver", 107.868, 0.172, 0.145)
cadmium       = Element(48, "Cd", "cadmium", 112.411, 0.158, 0.144)
indium        = Element(49, "In", "indium", 114.818, 0.193, 0.142)
tin           = Element(50, "Sn", "tin", 118.711, 0.217, 0.139)
antimony      = Element(51, "Sb", "antimony", 121.760, 0.200, 0.139)
tellurium     = Element(52, "Te", "tellurium", 127.600, 0.206, 0.147)
iodine        = Element(53,  "I", "iodine", 126.904, 0.198, 0.140)
xenon         = Element(54, "Xe", "xenon", 131.294, 0.216, 0.150)
cesium        = Element(55, "Cs", "cesium", 132.905, 0.200, 0.244)
barium        = Element(56, "Ba", "barium", 137.327, 0.200, 0.215)
lanthanum     = Element(57, "La", "lanthanum", 138.905, 0.200, 0.207)
cerium        = Element(58, "Ce", "cerium", 140.116, 0.200, 0.204)
praseodymium  = Element(59, "Pr", "praseodymium", 140.908, 0.200, 0.203)
neodymium     = Element(60, "Nd", "neodymium", 144.242, 0.200, 0.201)
promethium    = Element(61, "Pm", "promethium", 145.0, 0.200, 0.199)
samarium      = Element(62, "Sm", "samarium", 150.360, 0.200, 0.198)
europium      = Element(63, "Eu", "europium", 151.964, 0.200, 0.198)
gadolinium    = Element(64, "Gd", "gadolinium", 157.250, 0.200, 0.196)
terbium       = Element(65, "Tb", "terbium", 158.925, 0.200, 0.194)
dysprosium    = Element(66, "Dy", "dysprosium", 162.500, 0.200, 0.192)
holmium       = Element(67, "Ho", "holmium", 164.930, 0.200, 0.192)
erbium        = Element(68, "Er", "erbium", 167.259, 0.200, 0.189)
thulium       = Element(69, "Tm", "thulium", 168.934, 0.200, 0.190)
ytterbium     = Element(70, "Yb", "ytterbium", 173.054, 0.200, 0.187)
lutetium      = Element(71, "Lu", "lutetium", 174.967, 0.200, 0.187)
hafnium       = Element(72, "Hf", "hafnium", 178.490, 0.200, 0.175)
tantalum      = Element(73, "Ta", "tantalum", 180.948, 0.200, 0.170)
tungsten      = Element(74,  "W", "tungsten", 183.840, 0.200, 0.162)
rhenium       = Element(75, "Re", "rhenium", 186.207, 0.200, 0.151)
osmium        = Element(76, "Os", "osmium", 190.230, 0.200, 0.144)
iridium       = Element(77, "Ir", "iridium", 192.217, 0.200, 0.141)
platinum      = Element(78, "Pt", "platinum", 195.084, 0.172, 0.136)
gold          = Element(79, "Au", "gold", 196.967, 0.166, 0.150)
mercury       = Element(80, "Hg", "mercury", 200.590, 0.155, 0.132)
thallium      = Element(81, "Tl", "thallium", 204.383, 0.196, 0.145)
lead          = Element(82, "Pb", "lead", 207.200, 0.202, 0.146)
bismuth       = Element(83, "Bi", "bismuth", 208.980, 0.200, 0.148)
polonium      = Element(84, "Po", "polonium", 209.0, 0.200, 0.140)
astatine      = Element(85, "At", "astatine", 210.0, 0.200, 0.121)
radon         = Element(86, "Rn", "radon", 222.0, 0.200, 0.150)
francium      = Element(87, "Fr", "francium", 223.0, 0.200, 0.260)
radium        = Element(88, "Ra", "radium", 226.0, 0.200, 0.150)
actinium      = Element(89, "Ac", "actinium", 227.0, 0.200, 0.215)
thorium       = Element(90, "Th", "thorium", 232.038, 0.200, 0.206)
protactinium  = Element(91, "Pa", "protactinium", 231.036, 0.200, 0.200)
uranium       = Element(92,  "U", "uranium", 238.029, 0.186, 0.196)
neptunium     = Element(93, "Np", "neptunium", 237.0, 0.200, 0.190)
plutonium     = Element(94, "Pu", "plutonium", 244.0, 0.200, 0.187)
americium     = Element(95, "Am", "americium", 243.0, 0.200, 0.180)
curium        = Element(96, "Cm", "curium", 247.0, 0.200, 0.169)
berkelium     = Element(97, "Bk", "berkelium", 247.0, 0.200, 0.154)
californium   = Element(98, "Cf", "californium", 251.0, 0.200, 0.183)
einsteinium   = Element(99, "Es", "einsteinium", 252.0, 0.200, 0.150)
fermium       = Element(100, "Fm", "fermium", 257.0, 0.200, 0.150)
mendelevium   = Element(101, "Md", "mendelevium", 258.0, 0.200, 0.150)
nobelium      = Element(102, "No", "nobelium", 259.0, 0.200, 0.150)
lawrencium    = Element(103, "Lr", "lawrencium", 262.0, 0.200, 0.150)
rutherfordium = Element(104, "Rf", "rutherfordium", 267.0, 0.200, 0.150)
dubnium       = Element(105, "Db", "dubnium", 268.0, 0.200, 0.150)
seaborgium    = Element(106, "Sg", "seaborgium", 269.0, 0.200, 0.150)
bohrium       = Element(107, "Bh", "bohrium", 270.0, 0.200, 0.150)
hassium       = Element(108, "Hs", "hassium", 269.0, 0.200, 0.150)
meitnerium    = Element(109, "Mt", "meitnerium", 278.0, 0.200, 0.150)
darmstadtium  = Element(110, "Ds", "darmstadtium", 281.0, 0.200, 0.150)
roentgenium   = Element(111, "Rg", "roentgenium", 281.0)
copernicium   = Element(112, "Cn", "copernicium", 285.0)
ununtrium     = Element(113, "Uut", "ununtrium", 286.0)
flerovium     = Element(114, "Fl", "flerovium", 289.0)
ununpentium   = Element(115, "Uup", "ununpentium", 288.0)
livermorium   = Element(116, "Lv", "livermorium", 293.0)
ununseptium   = Element(117, "Uus", "ununseptium", 294.0)
ununoctium    = Element(118, "Uuo", "ununoctium", 294.0)

unknown       = Element( 0, "??", "unknown element")

caesium = cesium
aluminium = aluminum
sulphur = sulfur
ununnilium = darmstadtium

def from_symbol(symbol):
    return _elements_by_symbol.get(symbol, unknown)
